<?php
/*
	插件概览
*/
defined('BY_JYA') or exit('error');
$_RQ['op']=$_RQ['op']?$_RQ['op']:'get';
if($_RQ['op']=='get'){
	//显示统计数据
	$order['all']=pdo_count('jy_gohome_order',array('uniacid'=>$_SESSION['uniacid'],'status'=>1)) + pdo_count('jy_gohome_order',array('uniacid'=>$_SESSION['uniacid'],'status'=>2))+pdo_count('jy_gohome_order',array('uniacid'=>$_SESSION['uniacid'],'status'=>4));
	$day1=pdo_count('jy_gohome_order',array('uniacid'=>$_SESSION['uniacid'],'status'=>1,'createtime >'=>strtotime(date('y-m-d'))));
	$day2=pdo_count('jy_gohome_order',array('uniacid'=>$_SESSION['uniacid'],'status'=>2,'createtime >'=>strtotime(date('y-m-d'))));
	$day3=pdo_count('jy_gohome_order',array('uniacid'=>$_SESSION['uniacid'],'status'=>4,'createtime >'=>strtotime(date('y-m-d'))));
	$order['day']=$day1+$day2+$day3;
	//总业绩
	$day=date("Y-m-d",time("day"));
	$sql1 = "SELECT SUM(pay) FROM " . tablename('jy_gohome_order') . " WHERE uniacid=:uniacid AND status=1";
    $all_money1 = pdo_fetch($sql1,array(":uniacid" => $_SESSION['uniacid']));
	$sql2 = "SELECT SUM(pay) FROM " . tablename('jy_gohome_order') . " WHERE uniacid=:uniacid AND status=2";
    $all_money2 = pdo_fetch($sql2,array(":uniacid" => $_SESSION['uniacid']));
	$sql3 = "SELECT SUM(pay) FROM " . tablename('jy_gohome_order') . " WHERE uniacid=:uniacid AND status=4";
    $all_money3 = pdo_fetch($sql3,array(":uniacid" => $_SESSION['uniacid']));
//	print_r($all_money2);exit;
	//今日业绩
	$sql4 = "SELECT SUM(pay) FROM " . tablename('jy_gohome_order') . " WHERE uniacid=:uniacid AND day=:day AND status=4";
    $today_money1 = pdo_fetch($sql4,array(":uniacid" => $_SESSION['uniacid'],":day" => $day));
	$sql5 = "SELECT SUM(pay) FROM " . tablename('jy_gohome_order') . " WHERE uniacid=:uniacid AND day=:day AND status=2";
    $today_money2 = pdo_fetch($sql5,array(":uniacid" => $_SESSION['uniacid'],":day" => $day));
	$sql6 = "SELECT SUM(pay) FROM " . tablename('jy_gohome_order') . " WHERE uniacid=:uniacid AND day=:day AND status=1";
    $today_money3 = pdo_fetch($sql6,array(":uniacid" => $_SESSION['uniacid'],":day" => $day));
	$money['all']=$all_money1['SUM(pay)']+$all_money2['SUM(pay)']+$all_money3['SUM(pay)'];
	$money['day']=$today_money1['SUM(pay)']+$today_money2['SUM(pay)']+$today_money3['SUM(pay)'];
	
	$order['table']=pdo_count('jy_gohome_order',array('uniacid'=>$_SESSION['uniacid'],'status'=>3));
	$order['out']=pdo_count('jy_gohome_order',array('uniacid'=>$_SESSION['uniacid'],'status'=>3));
	$order['self']=pdo_count('jy_gohome_order',array('uniacid'=>$_SESSION['uniacid'],'status'=>3));
	$order['yuyue']=pdo_count('jy_gohome_order',array('uniacid'=>$_SESSION['uniacid'],'status'=>3));
	
	$money['table']=pdo_count('jy_gohome_order',array('uniacid'=>$_SESSION['uniacid'],'status'=>3));
	$money['out']=pdo_count('jy_gohome_order',array('uniacid'=>$_SESSION['uniacid'],'status'=>3));
	$money['self']=pdo_count('jy_gohome_order',array('uniacid'=>$_SESSION['uniacid'],'status'=>3));
	$money['yuyue']=pdo_count('jy_gohome_order',array('uniacid'=>$_SESSION['uniacid'],'status'=>3));
	$htmls=array(
		array('type'=>'data','num'=>12,'one_num'=>3,'title'=>'总运营数据','datas'=>array(
			array('title'=>'总订单数','num'=>1,'data'=>$order['all']),
			array('title'=>'订单金额','num'=>1,'data'=>$money['all'].'元'),
			array('title'=>'访客统计','num'=>1,'data'=>1),
			array('title'=>'总用户','num'=>1,'data'=>1),
		)),
		array('type'=>'data','num'=>12,'one_num'=>3,'title'=>'今日运营数据','datas'=>array(
			array('title'=>'订单数','num'=>1,'data'=>$order['day']),
			array('title'=>'订单金额','num'=>1,'data'=>$money['day']),
			array('title'=>'访客统计','num'=>1,'data'=>1),
			array('title'=>'今日用户','num'=>1,'data'=>1),
		)),
		array('type'=>'echarts_pie','one_num'=>2,'num'=>6,'ecid'=>'wechat','title'=>'服务项目分布图','datas'=>array(
					'time' => date("Y-m-d H:i:s", time()),
					'datas'=>array(
						array('name'=>'上门保洁','value'=>$order['table']),
						array('name'=>'服务SPA','value'=>$order['out']),
						array('name'=>'物业维修','value'=>$order['self']),
						array('name'=>'洗衣保洁','value'=>$order['yuyue']),
					),
		)),
		array('type'=>'echarts_pie','one_num'=>2,'num'=>6,'ecid'=>'wxapp','title'=>'员工业绩分布图','datas'=>array(
					'time' => date("Y-m-d H:i:s", time()),
					'datas'=>array(
						array('name'=>'技师-娜娜','value'=>$money['table']),
						array('name'=>'技师-芳芳','value'=>$money['table']),
						array('name'=>'技师-程程','value'=>$money['table']),
						array('name'=>'技师-小薇','value'=>$money['table']),
					),
		)),
	);
	$return=array('htmls'=>$htmls);
	exi($return);
}